home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / pascal / twins.com / TWINS.DOC < prev    next >
Encoding:
Text File  |  1979-11-30  |  29.7 KB  |  1,330 lines

  1.                      (***********************************)
  2.                      (*       TWINS Version 1.10        *)
  3.                      (***********************************)
  4.                      (*     Object -Oriented Windows    *)
  5.                      (*  for Turbo Pascal Version 5.5   *)
  6.                      (*         Copyright 1990          *)
  7.                      (*          Brian Corll            *)
  8.                      (*       All Rights Reserved       *)
  9.                      (***********************************)
  10.                      (***********************************)
  11.                      (*   Turbo Pascal is a registered  *)
  12.                      (* trademark of Borland Int. Corp. *)
  13.                      (***********************************)
  14.                      (*   Portions Copyright 1984,1989  *)
  15.                      (*    Borland International Corp.  *)
  16.                      (***********************************)
  17.                      (***********************************)
  18.  
  19.  
  20. INTRODUCTION
  21.  
  22.    Welcome to TWINS  Version 1.10 ! This toolbox  allows you to create
  23.    and  manipulate multiple  windows  on  visible and  virtual screens
  24.    using  the  object-oriented  techniques  available  in Turbo Pascal
  25.    Version 5.5.  Included are assembler routines  to facilitate direct
  26.    writes to video memory and the changing of text attributes. Also, a
  27.    unit has been provided to create simple light-bar menus and a color
  28.    selection menu, and a unit for detection of keyboard activity.
  29.  
  30.    This toolbox is  COPYRIGHTED SHAREWARE and is NOT  PUBLIC DOMAIN OR
  31.    FREE ! You may use it for a period of up to ninety days to evaluate
  32.    its usefulness  to you. If you  continue to use it  past the ninety
  33.    day  period, please  register your   copy and  help me  continue to
  34.    develop inexpensive toolboxes for Turbo  Pascal. You'll be glad you
  35.    did ! See the file  REGISTER.100 for details. Registered users will
  36.    receive  the complete  source for WINDOWS.TPU,SCREENS.TPU,MENUS.TPU
  37.    AND KEYS.TPU. Sorry, but the assembler source is not for sale.
  38.  
  39.    Private, non-profit users may register for $ 15.00.
  40.    Commercial and government users may register for $ 25.00.
  41.    Upgrades to the next major  version are available for an additional
  42.    $ 5.00.
  43.  
  44.    DISCLAIMER
  45.  
  46.    This  program is  provided "as  is" without  warranty of  any kind,
  47.    either express or implied, including but not limited to the implied
  48.    warranty of merchantability and fitness for a specific purpose. The
  49.    entire risk  as to the quality  and performance of this  program is
  50.    with you.
  51.  
  52.    In  no event  will the  author be  liable to  you for  any damages,
  53.    including  any lost  profits, lost  savings or  other incidental or
  54.    consequential damages arising out of the use of or inability to use
  55.    this program.
  56.  
  57.    That  said, please  be assured  that I  have spent  many long hours
  58.    trying to make this toolbox the best  it can be, and I'm working to
  59.    make it even better !
  60.  
  61.    Now for the inner details:
  62.  
  63.  
  64. SCREENS.TPU
  65.  
  66. UNIT Screens;
  67.  
  68.  
  69. {$L Flash}   (* These are the assembler routines that are essential to
  70. {$L Attr}       this toolbox. These routines handle the direct video
  71. {$L Screen}     memory access that this toolbox depends on. *)
  72. {$L Movers}
  73.  
  74.  
  75. INTERFACE
  76.  
  77. Uses DOS;
  78.  
  79. TYPE
  80.  
  81.  Borders = String[6];
  82.  (* The window border characters are stored in this string. *)
  83.  
  84.  VertStr = String[25];
  85.  (* This string is used for vertical string writing. *)
  86.  
  87.  Direction = (Up,Down);
  88.  (* These direction flags are used for screen scrolling. *)
  89.  
  90. CONST
  91.  
  92.  (* These are the predefined border character strings.  Feel free to
  93.     define your own ! *)
  94.  
  95.  SolidBrdr   : Borders = '██████';
  96.  SingleBrdr  : Borders = '┌└┐┘─│';
  97.  DoubleBrdr  : Borders = '╔╚╗╝═║';
  98.  Stars       : Borders = '******';
  99.  QuarterTone : Borders = '░░░░░░';
  100.  HalfTone    : Borders = '▒▒▒▒▒▒';
  101.  Chr254      : Borders = '■■■■■■';
  102.  
  103.  (* Color constants - defined to take advantage of Turbo Pascal's
  104.  constant folding capabilities. *)
  105.  
  106.  
  107.   Black        = $00;       DarkGray     = $08;
  108.   Blue         = $01;       LightBlue    = $09;
  109.   Green        = $02;       LightGreen   = $0A;
  110.   Cyan         = $03;       LightCyan    = $0B;
  111.   Red          = $04;       LightRed     = $0C;
  112.   Magenta      = $05;       LightMagenta = $0D;
  113.   Brown        = $06;       Yellow       = $0E;
  114.   LightGray    = $07;       White        = $0F;
  115.   Blink        = $80;
  116.  
  117.   BlackBG      = $00;
  118.   BlueBG       = $10;
  119.   GreenBG      = $20;
  120.   CyanBG       = $30;
  121.   RedBG        = $40;
  122.   MagentaBG    = $50;
  123.   BrownBG      = $60;
  124.   LightGrayBG  = $70;
  125.  
  126.  
  127.  
  128. TYPE
  129.  
  130.  ScreenType = Array[0..3999] of Byte;
  131.  (* An array buffer used to store an entire screen. *)
  132.  
  133.  ScrPtr = ^ScreenType;
  134.  (* A pointer to the above array. *)
  135.  
  136.  DisplayType = (Monochrome, CGA, EGA, MCGA, VGA);
  137.  (* An enumerated type used in determining the video card type *)
  138.  
  139. VAR
  140.  VideoBase : WORD;
  141.  (* The base address of video memory.  *)
  142.  
  143.  VideoWait : BOOLEAN;
  144.  (* If TRUE, video writes wait for horizontal retrace. *)
  145.  
  146.  SnowCheck : BOOLEAN;
  147.  (* If TRUE, CGA video snow checking is turned on. *)
  148.  
  149.  VideoOffset : BYTE;
  150.  (* The offset of the current character/attribute byte from the video
  151.     memory base address. *)
  152.  
  153.  VideoMode : BYTE;
  154.  (* The current video mode, 0..3 *)
  155.  
  156.  VideoWidth : BYTE;
  157.  (* The width of the current video page. *)
  158.  
  159.  VideoPage  : BYTE;
  160.  (* The current video page number. *)
  161.  
  162.  Mono : BOOLEAN;
  163.  (* If TRUE, a monochrome monitor is in use. *)
  164.  
  165.  Regs : Registers;
  166.  (* The CPU's registers. *)
  167.  
  168.  VidMode : BYTE;
  169.  (* The video  mode is stored here for use  by the assembler
  170.     routines. *)
  171.  
  172. (***************************************************)
  173. (*             PROCEDURES AND FUNCTIONS            *)
  174. (***************************************************)
  175.  
  176. PROCEDURE MoveWord (VAR Source,Dest; Count : WORD);
  177. (* Word-size moves *)
  178.  
  179. Usage:
  180.  
  181. PROGRAM EXAMPLE;
  182.  
  183. Uses Screens;
  184.  
  185. VAR
  186.    T1,T2 : ARRAY[1..100] OF BYTE;
  187.  
  188. BEGIN
  189.    MoveWord(T1,T2,100);
  190. END.
  191.  
  192. *******************************************************
  193.  
  194. FUNCTION  SaveScreen : ScrPtr;
  195. (* Saves the entire screen in VAR of type ScrPtr *)
  196.  
  197. Usage:
  198.  
  199. PROGRAM EXAMPLE;
  200.  
  201. Uses Screens,Windows;
  202.  
  203. VAR
  204.    InitScreen : ScrPtr;
  205.  
  206. BEGIN
  207.    InitScreen := SaveScreen;
  208.    RestoreScreen(InitScreen);
  209. END.
  210.  
  211. ***************************************************
  212.  
  213. PROCEDURE RestoreScreen(VAR SavedScreen : ScrPtr);
  214. (* Restores screen previously saved in VAR of type ScrPtr *)
  215.  
  216. Usage:
  217.  
  218. PROGRAM EXAMPLE;
  219.  
  220. Uses Screens,Windows;
  221.  
  222. VAR
  223.    InitScreen : ScrPtr;
  224.  
  225. BEGIN
  226.    InitScreen := SaveScreen;
  227.    RestoreScreen(InitScreen);
  228. END.
  229.  
  230. ***************************************************
  231.  
  232. PROCEDURE RestScr(SRow,SCol,ERow,ECol : BYTE;VAR Buffer : POINTER);
  233. (* Restores an area of a screen previously saved in a buffer *)
  234.  
  235. Usage:
  236.  
  237. PROGRAM EXAMPLE;
  238.  
  239. Uses Screens,Windows;
  240.  
  241. VAR
  242.    ScrBuffer : POINTER;
  243.  
  244. BEGIN
  245.    RestScr(10,20,15,60,ScrBuffer);
  246. END.
  247.  
  248. ***************************************************
  249.  
  250. PROCEDURE SaveScr(SRow,SCol,ERow,ECol : BYTE;VAR Buffer : POINTER);
  251. (* Saves an area of a screen in a buffer *)
  252.  
  253. Usage:
  254.  
  255. PROGRAM EXAMPLE;
  256.  
  257. Uses Screens,Windows;
  258.  
  259. VAR
  260.    ScrBuffer : POINTER;
  261.  
  262. BEGIN
  263.    SaveScr(10,20,15,60,ScrBuffer);
  264. END.
  265.  
  266. ***************************************************
  267.  
  268. PROCEDURE Flash(Row,Col, Attr:byte; Str : String);
  269. (* Writes a string directly to video memory *)
  270.  
  271. Usage:
  272.  
  273. PROGRAM EXAMPLE;
  274.  
  275. Uses Screens,Windows;
  276.  
  277.  
  278. BEGIN
  279.    Flash(12,25,White+RedBG,'This is a test string !');
  280. END.
  281.  
  282. ***************************************************
  283.  
  284. PROCEDURE CursorOn;
  285. (* Need I explain this ?! *)
  286.  
  287. ***************************************************
  288.  
  289. PROCEDURE CursorOff;
  290. (* Or this ?! *)
  291.  
  292. ***************************************************
  293.  
  294. PROCEDURE BlockCursor;
  295. (* Turns on a block cursor. *)
  296.  
  297. ***************************************************
  298.  
  299. PROCEDURE DrawBox(Row1,Col1,Row2,Col2 : Byte;Color : Byte;BorderType : Borders);
  300. (*  Draws  a  colored  box   on  the  screen  using  specified  border
  301.     characters. *)
  302.  
  303. Usage:
  304.  
  305. PROGRAM EXAMPLE;
  306.  
  307. Uses Screens,Windows;
  308.  
  309.  
  310. BEGIN
  311.    DrawBox(10,20,15,60,LightCyan+BlackBG,SingleBrdr);
  312. END.
  313.  
  314. ***************************************************
  315.  
  316. PROCEDURE ChAttr(Number : Word; Row, Col, Attr : Word);
  317. (* Changes a  specified number of video attributes  at a specified row
  318.    and column *)
  319.  
  320. Usage:
  321.  
  322. PROGRAM EXAMPLE;
  323.  
  324. Uses Screens,Windows;
  325.  
  326.  
  327. BEGIN
  328.    ChAttr(15,10,20,White+RedBG);
  329. END.
  330.  
  331. ***************************************************
  332.  
  333. PROCEDURE ChAllAttr(Row,Col,Rows,Cols,Attr : Word);
  334. (* Changes all text attributes in a specified area. *)
  335.  
  336. Usage:
  337.  
  338. PROGRAM EXAMPLE;
  339.  
  340. Uses Screens,Windows;
  341.  
  342.  
  343. BEGIN
  344.    ChAllAttr(10,20,5,40,White+RedBG);
  345. END.
  346.  
  347. ***************************************************
  348.  
  349.  
  350. PROCEDURE FlashC(Row,Attr:Byte;Str : String);
  351. (* Does a direct video write of a string, centered in a specified
  352.    row. *)
  353.  
  354. Usage:
  355.  
  356. PROGRAM EXAMPLE;
  357.  
  358. Uses Screens,Windows;
  359.  
  360.  
  361. BEGIN
  362.    FlashC(1,White+BlueBG,'This string is centered.');
  363. END.
  364.  
  365. ***************************************************
  366.  
  367. PROCEDURE Vertical(Row,Col,Color : BYTE;Str : VertStr);
  368. (* Writes a string vertically *)
  369.  
  370. Usage:
  371.  
  372. PROGRAM EXAMPLE;
  373.  
  374. Uses Screens,Windows;
  375.  
  376.  
  377. BEGIN
  378.    Vertical(1,10,White+MagentaBG,'This string is vertical !');
  379. END.
  380.  
  381. ***************************************************
  382.  
  383. PROCEDURE Diagonal(Row,Col,Color,Increment : BYTE;Str : String);
  384. (*  Writes  a  string  diagonally,  using  a  specified  increment for
  385.     increasing row and column numbers. *)
  386.  
  387. Usage:
  388.  
  389. PROGRAM EXAMPLE;
  390.  
  391. Uses Screens,Windows;
  392.  
  393.  
  394. BEGIN
  395.    Diagonal(1,10,White+MagentaBG,2'This string is vertical !');
  396. END.
  397.  
  398. ***************************************************
  399.  
  400. PROCEDURE HBar(Row,Col,Len,Color : BYTE;BarChar : CHAR);
  401. (* Creates a horizontal textmode bar *)
  402.  
  403. Usage:
  404.  
  405. PROGRAM EXAMPLE;
  406.  
  407. Uses Screens,Windows;
  408.  
  409.  
  410. BEGIN
  411.    HBar(1,10,20,White+MagentaBG,#176);
  412. END.
  413.  
  414. ***************************************************
  415.  
  416. PROCEDURE VBar(Row,Col,Len,Color : BYTE;BarStr : String);
  417. (* Creates a vertical textmode bar *)
  418.  
  419. Usage:
  420.  
  421. PROGRAM EXAMPLE;
  422.  
  423. Uses Screens,Windows;
  424.  
  425.  
  426. BEGIN
  427.    VBar(1,10,20,White+MagentaBG,'XXX');
  428. END.
  429.  
  430. ***************************************************
  431.  
  432. PROCEDURE Scroll(NumLines,SRow,SCol,ERow,ECol,Color : BYTE;
  433.    WhichWay : Direction);
  434. (* Scrolls a screen region.  NumLines = 0 clears the screen region. *)
  435.  
  436. Usage:
  437.  
  438. PROGRAM EXAMPLE;
  439.  
  440. Uses Screens,Windows;
  441.  
  442.  
  443. BEGIN
  444.    Scroll(1,10,20,15,60,Red,Up);
  445. END.
  446.  
  447. ***************************************************
  448.  
  449. PROCEDURE GetVideoStatus;
  450. (* Gets current video status and returns it in global VARS VideoMode,
  451.    VideoWidth,VideoPage *)
  452.  
  453. Usage:
  454.  
  455. PROGRAM EXAMPLE;
  456.  
  457. Uses Screens,Windows;
  458.  
  459.  
  460. BEGIN
  461.    GetVideoStatus;
  462. END.
  463.  
  464. ***************************************************
  465.  
  466. PROCEDURE SetVideoMode(Mode : BYTE);
  467. (* Select a video mode from 0..3 *)
  468.  
  469. Usage:
  470.  
  471. PROGRAM EXAMPLE;
  472.  
  473. Uses Screens,Windows;
  474.  
  475.  
  476. BEGIN
  477.    SetVideoMode(3);
  478. END.
  479.  
  480. ***************************************************
  481.  
  482. PROCEDURE SetVisiblePage(Page : BYTE);
  483. (* Sets visible video page 0..3 *)
  484.  
  485. Usage:
  486.  
  487. PROGRAM EXAMPLE;
  488.  
  489. Uses Screens,Windows;
  490.  
  491.  
  492. BEGIN
  493.    SetVisiblePage(0);
  494. END.
  495.  
  496. See the file SCRDEMO.PAS for a demonstration of video text paging.
  497.  
  498. ***************************************************
  499.  
  500. PROCEDURE SetVirtualPage(Page : BYTE);
  501. (*  Set virtual  video page  0..3, allowing  you to  write to "hidden"
  502.     video  pages,  which  may  then  be  made  visible  with a call to
  503.     SetVisiblePage.  *)
  504.  
  505. Usage:
  506.  
  507. PROGRAM EXAMPLE;
  508.  
  509. Uses Screens,Windows;
  510.  
  511.  
  512. BEGIN
  513.    SetVirtualPage(1);
  514.    Flash(1,1,White,'This is page two !');
  515. END.
  516.  
  517. See the file SCRDEMO.PAS for a demonstration of video text paging.
  518.  
  519. ***************************************************
  520.  
  521. PROCEDURE ClearVirtualPage(Color : BYTE);
  522. (* Clear the  currently selected virtual page using  a specified color
  523.    attribute *)
  524.  
  525. Usage:
  526.  
  527. PROGRAM EXAMPLE;
  528.  
  529. Uses Screens,Windows;
  530.  
  531.  
  532. BEGIN
  533.    ClearVirtualPage(Black);
  534. END.
  535.  
  536. ***************************************************
  537.  
  538. FUNCTION  PrintScreen : BOOLEAN;
  539. (* Print a screen and return success/failure *)
  540.  
  541. Usage:
  542.  
  543. PROGRAM EXAMPLE;
  544.  
  545. Uses Screens,Windows;
  546.  
  547. VAR
  548.    Success : BOOLEAN;
  549.  
  550. BEGIN
  551.    Success := PrintScreen;
  552. END.
  553.  
  554. ***************************************************
  555.  
  556. PROCEDURE ClearScreen(SRow,SCol,ERow,ECol,Color : BYTE);
  557. (* Clear a screen region using a specified color attribute *)
  558.  
  559. Usage:
  560.  
  561. PROGRAM EXAMPLE;
  562.  
  563. Uses Screens,Windows;
  564.  
  565. BEGIN
  566.    ClearScreen(10,20,15,60,Red);
  567. END.
  568.  
  569. ***************************************************
  570.  
  571. FUNCTION GetFG(Color : BYTE) : BYTE;
  572. (* Returns the foreground color value of a color combination *)
  573.  
  574. Usage:
  575.  
  576. PROGRAM EXAMPLE;
  577.  
  578. Uses Screens,Windows;
  579.  
  580. VAR
  581.    Color : BYTE;
  582.    FG : BYTE;
  583.  
  584. BEGIN
  585.    Color := White+RedBG;
  586.    FG := GetFG(Color);
  587. END.
  588.  
  589. ***************************************************
  590.  
  591. FUNCTION GetBG(Color : BYTE) : BYTE;
  592. (* Returns the background color value of a color combination *)
  593.  
  594. Usage:
  595.  
  596. PROGRAM EXAMPLE;
  597.  
  598. Uses Screens,Windows;
  599.  
  600. VAR
  601.    Color : BYTE;
  602.    BG : BYTE;
  603.  
  604. BEGIN
  605.    Color := White+RedBG;
  606.    BG := GetFG(Color);
  607. END.
  608.  
  609. ***************************************************
  610.  
  611. PROCEDURE FillScreen(Character : CHAR;Attr : BYTE);
  612. (* Fills the entire screen with a specified character and attribute *)
  613.  
  614. Usage:
  615.  
  616. PROGRAM EXAMPLE;
  617.  
  618. Uses Screens,Windows;
  619.  
  620. BEGIN
  621.    FillScreen(#178,White+RedBG);
  622. END.
  623.  
  624. ***************************************************
  625.  
  626. PROCEDURE FillArea(Row,Col,Rows,Cols,Attr : Byte;Ch : Char);
  627. (*  Fills  a  specified  area  of  the  screen with a specified
  628.     character and attribute. *)
  629.  
  630. Usage:
  631.  
  632. PROGRAM EXAMPLE;
  633.  
  634. Uses Screens,Windows;
  635.  
  636. BEGIN
  637.    FillArea(1,1,10,20,White+RedBG,#178);
  638. END.
  639.  
  640.  
  641. ***************************************************
  642. PROCEDURE CopyScreen(TLRow,TLCol,BRRow,BRCol,NewTLRow,NewTLCol : BYTE);
  643. (* Copies a specified screen area to a new area of the screen. See the
  644. demo file SCRTEST.PAS *)
  645.  
  646.  
  647. ***************************************************
  648.  
  649. WINDOWS.TPU
  650.  
  651. UNIT WINDOWS;
  652.  
  653. INTERFACE
  654.  
  655. Uses Screens;
  656.  
  657. CONST
  658.  Shadow =  TRUE; (* These  BOOLEAN constants are  used to turn  window
  659.                   shadows on or off. *)
  660.  NoShadow = FALSE;
  661.  
  662.  
  663.   (* These window borders are defined in SCREENS.PAS:
  664.   SolidBrdr   : Borders = '██████';
  665.   SingleBrdr  : Borders = '┌└┐┘─│';
  666.   DoubleBrdr  : Borders = '╔╚╗╝═║';
  667.   Stars       : Borders = '******';
  668.   QuarterTone : Borders = '░░░░░░';
  669.   HalfTone    : Borders = '▒▒▒▒▒▒'; *)
  670.  
  671. TYPE
  672.  
  673.   Positions = (Left,Right,Center);
  674.   (* An enumerated type used in defining window title positions. *)
  675.  
  676.   Str80 = String[80];
  677.  
  678.   WindowPtr = ^WindowObject;
  679.   (* Pointer to window object *)
  680.  
  681.   WindowObject = OBJECT
  682.   WSRow,WERow,WSCol,WECol : BYTE;
  683.   (* Starting and ending rows and columns of window *)
  684.  
  685.   WinBuf : POINTER;
  686.   (* Pointer to screen save buffer *)
  687.  
  688.   WFAttr,WBAttr : BYTE;
  689.   (* Foreground and background attributes *)
  690.  
  691.   WinFill : CHAR;
  692.   (* Window fill character *)
  693.  
  694.   WinFrame : Borders;
  695.   (* Window frame *)
  696.  
  697.   WinTitle : Str80;
  698.   (* Window title *)
  699.  
  700.   WinTitlePos : Positions;
  701.   (* Window title position *)
  702.  
  703.   ShadowOn : BOOLEAN;
  704.   (* Turns shadows on/off *)
  705.  
  706.   Active : BOOLEAN;
  707.   (* Stores active/inactive status of window *)
  708.  
  709.  PROCEDURE SaveWin;
  710.  (* Save a screen region to a buffer *)
  711.  
  712.  PROCEDURE RestWin;
  713.  (* Restore a screen region from a buffer *)
  714.  
  715.  PROCEDURE MakeWin(SRow,SCol,ERow,ECol,FAttr,BAttr : BYTE;
  716.    Frame : Borders;FillChar : CHAR;Shadow : BOOLEAN);
  717.    (* Create a window *)
  718.  
  719.  PROCEDURE RemoveWin;
  720.  (* Remove a window *)
  721.  
  722.  PROCEDURE FillWin(FillChar : CHAR);
  723.  (* Fill a window with a specified character *)
  724.  
  725.  PROCEDURE ChFrameAttr(NewAttr : BYTE);
  726.  (* Change window frame attribute *)
  727.  
  728.  PROCEDURE ChFrame(NewFrame : Borders);
  729.  (* Change frame style *)
  730.  
  731.  PROCEDURE WriteWin(WRow,WCol : BYTE;WriteStr : String);
  732.  (* Write a string in a window *)
  733.  
  734.  PROCEDURE WriteWinC(WRow : BYTE;WriteStr : String);
  735.  (* Write a string in a window, centered *)
  736.  
  737.  PROCEDURE TitleWin(Where : Positions;Title : Str80);
  738.  (* Title a window *)
  739.  
  740.  PROCEDURE ScrollWin(NumLines : BYTE;WhichWay : Direction);
  741.  (* Scroll window contents NumLines lines up or down *)
  742.  
  743.  PROCEDURE ClearWin;
  744.  (* Clear window *)
  745.  
  746.  PROCEDURE MoveWin(NewSRow,NewSCol : BYTE);
  747.  (* Move window to new row and column *)
  748.  
  749.  CONSTRUCTOR Init;
  750.  (* Initialize an object instance *)
  751.  
  752.  DESTRUCTOR Done;
  753.  (* Destroy an object instance *)
  754.  
  755.  END;
  756.  
  757. VAR
  758.  ShadowColor : BYTE; (* The color used to create shadows *)
  759.  LastWindow : BYTE;  (* the highest window number currently active *)
  760.  
  761. (*******************************************)
  762. (*                 METHODS                 *)
  763. (*******************************************)
  764.  
  765. PROCEDURE SaveWin;
  766. (* Save a screen region to a buffer *)
  767.  
  768. Used internally by TWINS.
  769.  
  770.  
  771. ***************************************************
  772.  
  773. PROCEDURE RestWin;
  774. (* Restore a screen region from a buffer *)
  775.  
  776. Uses internally by TWINS.
  777.  
  778. ***************************************************
  779.  
  780. PROCEDURE MakeWin(SRow,SCol,ERow,ECol,FAttr,BAttr : BYTE;
  781.    Frame : Borders;FillChar : CHAR;Shadow : BOOLEAN);
  782. (* Create a window *)
  783.    SRow,SCol = Upper left corner row and column
  784.    ERow,ECol = Lower right corner row and column
  785.    FAttr,BAttr = foreground and background attribute bytes
  786.    Frame = frame type (see BORDERS constants in above )
  787.    FillChar = the character used to create the window background
  788.    Shadow = If TRUE, the window has a shadow placed behind it
  789.  
  790. Usage:
  791.  
  792. PROGRAM EXAMPLE;
  793.  
  794. Uses Screens,Windows;
  795.  
  796. VAR
  797.    Test : WindowPtr;
  798.  
  799. BEGIN
  800.    NEW(Test,Init);
  801.    Test^.MakeWin(10,20,15,60,White+RedBG,RedBG,DoubleBrdr,#32,TRUE);
  802.    DISPOSE(Test,Done);
  803. END.
  804.  
  805. ***************************************************
  806.  
  807. PROCEDURE RemoveWin;
  808. (* Remove a window *)
  809.  
  810. Usage:
  811.  
  812. PROGRAM EXAMPLE;
  813.  
  814. Uses Screens,Windows;
  815.  
  816. VAR
  817.    Test : WindowPtr;
  818.  
  819. BEGIN
  820.    NEW(Test,Init);
  821.    Test^.MakeWin(10,20,15,60,White+RedBG,RedBG,DoubleBrdr,#32,TRUE);
  822.    Test^.RemoveWin;
  823.    DISPOSE(Test,Done);
  824. END.
  825.  
  826. ***************************************************
  827.  
  828. PROCEDURE FillWin(FillChar : CHAR);
  829. (* Fill a window with a specified character *)
  830.  
  831. Usage:
  832.  
  833. PROGRAM EXAMPLE;
  834.  
  835. Uses Screens,Windows;
  836.  
  837. VAR
  838.    Test : WindowPtr;
  839.  
  840. BEGIN
  841.    NEW(Test,Init);
  842.    Test^.MakeWin(10,20,15,60,White+RedBG,RedBG,DoubleBrdr,#32,TRUE);
  843.    Test^.FillWin(#176);
  844.    Test^.RemoveWin;
  845.    DISPOSE(Test,Done);
  846. END.
  847.  
  848. ***************************************************
  849.  
  850. PROCEDURE ChFrameAttr(NewAttr : BYTE);
  851. (* Change window frame attribute *)
  852.  
  853. Usage:
  854.  
  855. PROGRAM EXAMPLE;
  856.  
  857. Uses Screens,Windows;
  858.  
  859. VAR
  860.    Test : WindowPtr;
  861.  
  862. BEGIN
  863.    NEW(Test,Init);
  864.    Test^.MakeWin(10,20,15,60,White+RedBG,RedBG,DoubleBrdr,#32,TRUE);
  865.    Test^.ChFrameAttr(White+BlueBG);
  866.    Test^.RemoveWin;
  867.    DISPOSE(Test,Done);
  868. END.
  869.  
  870. ***************************************************
  871.  
  872. PROCEDURE ChFrame(NewFrame : Borders);
  873. (* Change frame style *)
  874.  
  875. Usage:
  876.  
  877. PROGRAM EXAMPLE;
  878.  
  879. Uses Screens,Windows;
  880.  
  881. VAR
  882.    Test : WindowPtr;
  883.  
  884. BEGIN
  885.    NEW(Test,Init);
  886.    Test^.MakeWin(10,20,15,60,White+RedBG,RedBG,DoubleBrdr,#32,TRUE);
  887.    Test^.ChFrame(SingleBrdr);
  888.    Test^.RemoveWin;
  889.    DISPOSE(Test,Done);
  890. END.
  891.  
  892. ***************************************************
  893.  
  894. PROCEDURE WriteWin(WRow,WCol : BYTE;WriteStr : String);
  895. (* Write a string in a window *)
  896.  
  897. Usage:
  898.  
  899. PROGRAM EXAMPLE;
  900.  
  901. Uses Screens,Windows;
  902.  
  903. VAR
  904.    Test : WindowPtr;
  905.  
  906. BEGIN
  907.    NEW(Test,Init);
  908.    Test^.MakeWin(10,20,15,60,White+RedBG,RedBG,DoubleBrdr,#32,TRUE);
  909.    Test^.WriteWin(10,25,'This is a test string');
  910.    Test^.RemoveWin;
  911.    DISPOSE(Test,Done);
  912. END.
  913.  
  914. ***************************************************
  915.  
  916. PROCEDURE WriteWinC(WRow : BYTE;WriteStr : String);
  917. (* Write a string in a window, centered *)
  918.  
  919. Usage:
  920.  
  921. PROGRAM EXAMPLE;
  922.  
  923. Uses Screens,Windows;
  924.  
  925. VAR
  926.    Test : WindowPtr;
  927.  
  928. BEGIN
  929.    NEW(Test,Init);
  930.    Test^.MakeWin(10,20,15,60,White+RedBG,RedBG,DoubleBrdr,#32,TRUE);
  931.    Test^.WriteWinC(10,'This is a test string');
  932.    Test^.RemoveWin;
  933.    DISPOSE(Test,Done);
  934. END.
  935.  
  936. ***************************************************
  937.  
  938. PROCEDURE TitleWin(Where : Positions;Title : Str80);
  939. (* Title a window *)
  940.  
  941. Usage:
  942.  
  943. PROGRAM EXAMPLE;
  944.  
  945. Uses Screens,Windows;
  946.  
  947. VAR
  948.    Test : WindowPtr;
  949.  
  950. BEGIN
  951.    NEW(Test,Init);
  952.    Test^.MakeWin(10,20,15,60,White+RedBG,RedBG,DoubleBrdr,#32,TRUE);
  953.    Test^.TitleWin(Center,'WINDOW 1');
  954.    Test^.RemoveWin;
  955.    DISPOSE(Test,Done);
  956. END.
  957.  
  958. ***************************************************
  959.  
  960. PROCEDURE ScrollWin(NumLines : BYTE;WhichWay : Direction);
  961. (* Scroll window contents NumLines lines  up or down. If NumLines = 0,
  962.    the window is cleared. *)
  963.  
  964. Usage:
  965.  
  966. PROGRAM EXAMPLE;
  967.  
  968. Uses Screens,Windows;
  969.  
  970. VAR
  971.    Test : WindowPtr;
  972.  
  973. BEGIN
  974.    NEW(Test,Init);
  975.    Test^.MakeWin(10,20,15,60,White+RedBG,RedBG,DoubleBrdr,#32,TRUE);
  976.    Test^.ScrollWin(1,Up);
  977.    Test^.RemoveWin;
  978.    DISPOSE(Test,Done);
  979. END.
  980.  
  981. ***************************************************
  982.  
  983. PROCEDURE ClearWin;
  984. (* Clear window *)
  985.  
  986. Usage:
  987.  
  988. PROGRAM EXAMPLE;
  989.  
  990. Uses Screens,Windows;
  991.  
  992. VAR
  993.    Test : WindowPtr;
  994.  
  995. BEGIN
  996.    NEW(Test,Init);
  997.    Test^.MakeWin(10,20,15,60,White+RedBG,RedBG,DoubleBrdr,#32,TRUE);
  998.    Test^.ClearWin;
  999.    Test^.RemoveWin;
  1000.    DISPOSE(Test,Done);
  1001. END.
  1002.  
  1003. ***************************************************
  1004.  
  1005. PROCEDURE MoveWin(NewSRow,NewSCol : BYTE);
  1006. (* Move window to new row and column *)
  1007.  
  1008. Usage:
  1009.  
  1010. PROGRAM EXAMPLE;
  1011.  
  1012. Uses Screens,Windows;
  1013.  
  1014. VAR
  1015.    Test : WindowPtr;
  1016.  
  1017. BEGIN
  1018.    NEW(Test,Init);
  1019.    Test^.MakeWin(10,20,15,60,White+RedBG,RedBG,DoubleBrdr,#32,TRUE);
  1020.    Test^.MoveWin(1,1);
  1021.    Test^.RemoveWin;
  1022.    DISPOSE(Test,Done);
  1023. END.
  1024.  
  1025. ***************************************************
  1026.  
  1027. CONSTRUCTOR Init;
  1028. (* Initialize an object instance *)
  1029.  
  1030. Usage:
  1031.  
  1032. PROGRAM EXAMPLE;
  1033.  
  1034. Uses Screens,Windows;
  1035.  
  1036. VAR
  1037.    Test : WindowPtr;
  1038.  
  1039. BEGIN
  1040.    NEW(Test,Init);
  1041.    Test^.MakeWin(10,20,15,60,White+RedBG,RedBG,DoubleBrdr,#32,TRUE);
  1042.    Test^.MoveWin(1,1);
  1043.    Test^.RemoveWin;
  1044.    DISPOSE(Test,Done);
  1045. END.
  1046.  
  1047. ***************************************************
  1048.  
  1049. DESTRUCTOR Done;
  1050. (* Destroy an object instance *)
  1051.  
  1052. Usage:
  1053.  
  1054. PROGRAM EXAMPLE;
  1055.  
  1056. Uses Screens,Windows;
  1057.  
  1058. VAR
  1059.    Test : WindowPtr;
  1060.  
  1061. BEGIN
  1062.    NEW(Test,Init);
  1063.    Test^.MakeWin(10,20,15,60,White+RedBG,RedBG,DoubleBrdr,#32,TRUE);
  1064.    Test^.MoveWin(1,1);
  1065.    Test^.RemoveWin;
  1066.    DISPOSE(Test,Done);
  1067. END.
  1068.  
  1069. ***************************************************
  1070.  
  1071. PROCEDURE FillArea(Row,Col,Rows,Cols,Attr : Byte;Ch : Char);
  1072. (* Fill a screen region with a specified color and attribute *)
  1073.  
  1074. Usage:
  1075.  
  1076. PROGRAM EXAMPLE;
  1077.  
  1078. Uses Screens,Windows;
  1079.  
  1080. VAR
  1081.    Test : WindowPtr;
  1082.  
  1083. BEGIN
  1084.    FillArea(1,1,25,80,Cyan+BlueBG,#178);
  1085.    NEW(Test,Init);
  1086.    Test^.MakeWin(10,20,15,60,White+RedBG,RedBG,DoubleBrdr,#32,TRUE);
  1087.    Test^.MoveWin(1,1);
  1088.    Test^.RemoveWin;
  1089.    DISPOSE(Test,Done);
  1090. END.
  1091.  
  1092. ***************************************************
  1093.  
  1094. MENUS.TPU
  1095.  
  1096.  
  1097.  
  1098. UNIT Menus;
  1099.  
  1100. INTERFACE
  1101.  
  1102. Uses Dos,Screens,Windows,Keys;
  1103.  
  1104.  
  1105. TYPE
  1106. BlinkStatus = (BlinkOn,BlinkOff);
  1107. Str2 = String[2];
  1108. Str40 = String[40];
  1109. Str80 = String[80];
  1110.  
  1111.  
  1112. (* The menu definition record *)
  1113. MenuRec = RECORD
  1114.    Row,Col    : BYTE;
  1115.    MenuPrompt : String[40];
  1116.    MenuHelp   : String[80];
  1117.    MenuLevel  : String[2];
  1118.    END;
  1119.  
  1120. (* The menu defintion array *)
  1121.    MenuDesc = ARRAY[1..25] OF MenuRec;
  1122.  
  1123. PROCEDURE MenuDef(VAR TheMenu : MenuDesc;ItemNo : BYTE;Row,Col : BYTE;
  1124.    MPrompt : Str40;MHelp : Str80);
  1125.  
  1126. FUNCTION  Menu(MenuItems : MenuDesc;LoColor,HiColor,HelpColor : BYTE;
  1127.           FirstItem,NumItems : BYTE) : BYTE;
  1128.  
  1129. PROCEDURE CreateColorMenu(TLRow,TLCol : BYTE;ShowBlinking : BlinkStatus);
  1130.  
  1131. FUNCTION  ColorSelect : BYTE;
  1132.  
  1133. PROCEDURE DestroyColorMenu;
  1134.  
  1135.  
  1136.  
  1137. IMPLEMENTATION
  1138.  
  1139. (***************************************************)
  1140. (*             PROCEDURES AND FUNCTIONS            *)
  1141. (***************************************************)
  1142.  
  1143.  
  1144.  
  1145. PROCEDURE MenuDef(VAR TheMenu : MenuDesc;ItemNo : BYTE;Row,Col : BYTE;
  1146.    MPrompt : Str40;MHelp : Str80);
  1147. (* Defines an array of menu selection description records *)
  1148.  
  1149. Usage:
  1150.  
  1151. PROGRAM EXAMPLE;
  1152.  
  1153. Uses Screens,Windows,Menus;
  1154.  
  1155. VAR
  1156.    TestMenu : MenuDesc;
  1157.  
  1158. BEGIN
  1159.    MenuDef(TestMenu,1,1,20,'MENU SELECTION #1','This is menu selection number 1');
  1160. END.
  1161.  
  1162. *************************
  1163.  
  1164. FUNCTION  Menu(MenuItems : MenuDesc;LoColor,HiColor,HelpColor : BYTE;
  1165.           FirstItem,NumItems : BYTE) : BYTE;
  1166.  
  1167. Usage:
  1168.  
  1169. PROGRAM EXAMPLE;
  1170.  
  1171. Uses Screens,Windows,Menus;
  1172.  
  1173. VAR
  1174.    TestMenu : MenuDesc;
  1175.    Choice : BYTE;
  1176. BEGIN
  1177.    MenuDef(TestMenu,1,1,20,'MENU SELECTION #1','This is menu selection number 1');
  1178.    MenuDef(TestMenu,2,2,20,'MENU SELECTION #2','This is menu selection number 2');
  1179.    MenuDef(TestMenu,3,3,20,'MENU SELECTION #3','This is menu selection number 3');
  1180.    MenuDef(TestMenu,4,4,20,'MENU SELECTION #4','This is menu selection number 4');
  1181.    MenuDef(TestMenu,5,5,20,'MENU SELECTION #5','This is menu selection number 5');
  1182.    Choice := Menu(TestMenu,White+BlueBG,Black+LightGrayBG,Yellow+BlueBG,1,5);
  1183. END.
  1184.  
  1185. *********************************
  1186.  
  1187. The following  two procedures and a  function create a complete
  1188. color selection menu, allowing  the user to choose from  a menu of 128
  1189. or 256 colors, depending on whether the variable ShowBlinking is set to
  1190. BlinkOn or BlinkOff.
  1191.  
  1192.  
  1193. PROCEDURE CreateColorMenu(TLRow,TLCol : BYTE;ShowBlinking : BlinkStatus);
  1194.  
  1195. FUNCTION  ColorSelect : BYTE;
  1196.  
  1197. PROCEDURE DestroyColorMenu;
  1198.  
  1199.  
  1200.  
  1201. Usage:
  1202.  
  1203. PROGRAM EXAMPLE;
  1204.  
  1205. Uses Screens,Windows,Menus;
  1206.  
  1207. VAR
  1208.    Choice : BYTE;
  1209. BEGIN
  1210.    CreateColorMenu(2,2,BlinkOn);
  1211.    Choice := ColorSelect;
  1212.    DestroyColorMenu;
  1213. END.
  1214.  
  1215. ***************************************************
  1216.  
  1217.  
  1218. UNIT Keys;
  1219.  
  1220. INTERFACE
  1221.  
  1222. Uses Dos;
  1223.  
  1224. CONST
  1225.  
  1226.         (* Constants are defined for the most frequently used keys and
  1227.         combinations : *)
  1228.  
  1229.         NULL = #3;
  1230.         ShiftTab = #15;
  1231.         Return = #13;
  1232.         Escape = #27;
  1233.         Home = #71;
  1234.         UpArrow = #72;
  1235.         PgUp = #73;
  1236.         LeftArrow = #75;
  1237.         RightArrow = #77;
  1238.         EndKey = #79;
  1239.         DownArrow = #80;
  1240.         PgDn = #81;
  1241.         INS = #82;
  1242.         DEL = #83;
  1243.         Echo = #114;
  1244.         CtrlLeftArrow = #115;
  1245.         CtrlRightArrow = #116;
  1246.         CtrlEnd = #117;
  1247.         CtrlPgDn = #118;
  1248.         CtrlHome = #119;
  1249.         CtrlPgUp = #132;
  1250.  
  1251.  
  1252.  
  1253.         F1 = #59; F2 = #60; F3 = #61; F4 = #62; F5 = #63; F6 = #64;
  1254.         F7 = #65; F8 = #66; F9 = #67; F10 = #68;
  1255.  
  1256.         ShiftF1 = #84; ShiftF2 = #85; ShiftF3 = #86; ShiftF4 = #87; ShiftF5 = #88;
  1257.         ShiftF6 = #89; ShiftF7 = #90; ShiftF8 = #91; ShiftF9 = #92; ShiftF10 = #93;
  1258.  
  1259.         CtrlF1 = #94; CtrlF2 = #95; CtrlF3 = #96; CtrlF4 = #97; CtrlF5 = #98;
  1260.         CtrlF6 = #99; CtrlF7 = #100; CtrlF8 = #101; CtrlF9 = #102; CtrlF10 = #103;
  1261.  
  1262.         AltF1 = #104; AltF2 = #105; AltF3 = #106; AltF4 = #107; AltF5 = #108;
  1263.         AltF6 = #109; AltF7 = #110; AltF8 = #111; AltF9 = #112; AltF10 = #113;
  1264.  
  1265.         Alt1 = #120; Alt2 = #121; Alt3 = #122; Alt4 = #123; Alt5 = #124;
  1266.         Alt6 = #125; Alt7 = #126; Alt8 = #127; Alt9 = #128; Alt0 = #129;
  1267.         AltHyphen = #130; AltEqual = #131; AltQ = #16; AltW = #17; AltE = #18;
  1268.         AltR = #19; AltT = #20; AltY = #21; AltU = #22; AltI = #23; AltO = #24;
  1269.         AltP = #25; AltA = #30; AltS = #31; AltD = #32; AltF = #33; AltG = #34;
  1270.         AltH = #35; AltJ = #36; AltK = #37; AltL = #38; AltZ = #44; AltX = #45;
  1271.         AltC = #46; AltV = #47; AltB = #48; AltN = #49; AltM = #50;
  1272.  
  1273.  
  1274. VAR
  1275.         GlobalKey : CHAR;
  1276.         (* A 'fake' key used to simulate 'stuffing' the keyboard. *)
  1277.  
  1278.  
  1279. FUNCTION  Inkey : CHAR;
  1280. (* Returns the value of the last key pressed. This value will be equal
  1281.    to one of the constants defined above. *)
  1282.  
  1283. PROCEDURE KeyBoard(StuffChar : CHAR);
  1284. (*  Sets GlobalKey  equal to  the value  of StuffChar,  which is  then
  1285.     returned by the Inkey function *)
  1286.  
  1287. IMPLEMENTATION
  1288.  
  1289.  
  1290. (***************************************************)
  1291. (*               END OF DOCUMENTATION              *)
  1292. (***************************************************)
  1293.  
  1294.  
  1295.  
  1296.          ----------------end-of-author's-documentation---------------
  1297.  
  1298.                         Software Library Information:
  1299.  
  1300.                    This disk copy provided as a service of
  1301.  
  1302.                         The Public (Software) Library
  1303.  
  1304.          We are not the authors of this program, nor are we associated
  1305.          with the author in any way other than as a distributor of the
  1306.          program in accordance with the author's terms of distribution.
  1307.  
  1308.          Please direct shareware payments and specific questions about
  1309.          this program to the author of the program, whose name appears
  1310.          elsewhere in  this documentation. If you have trouble getting
  1311.          in touch with the author,  we will do whatever we can to help
  1312.          you with your questions. All programs have been tested and do
  1313.          run.  To report problems,  please use the form that is in the
  1314.          file PROBLEM.DOC on many of our disks or in other written for-
  1315.          mat with screen printouts, if possible.  The P(s)L cannot de-
  1316.          bug programs over the telephone.
  1317.  
  1318.          Disks in the P(s)L are updated monthly, so if you did not get
  1319.          this disk  directly from the P(s)L,  you should be aware that
  1320.          the files in this set may no  longer be the current versions.
  1321.  
  1322.          For a copy of the latest monthly software library newsletter
  1323.          and a list of the 1,000+ disks in the library, call or write
  1324.  
  1325.                         The Public (Software) Library
  1326.                               P.O.Box 35705
  1327.                            Houston, TX 77235-5705
  1328.                                (713) 665-7017
  1329.  
  1330.